home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11024 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  896 b 

  1. Path: iz.maus.de!Torsten_Landschoff
  2. From: Torsten_Landschoff@iz.maus.de (Torsten Landschoff)
  3. Newsgroups: comp.lang.c++
  4. Subject: iostream error recovery
  5. Message-ID: <199603102354.a35684@iz.maus.de>
  6. Date: Sun, 10 Mar 96 21:54:00 GMT
  7. References: <313CADB5.39AF@babbage.cs.qc.edu>
  8. X-Gate: MausGate/News 1.25/ac3
  9. MIME-Version: 1.0
  10. Content-Type: text/plain; charset=ISO-8859-1
  11. Content-Transfer-Encoding: 8bit
  12.  
  13. -A40484@AC3
  14.  
  15. Hi Christopher
  16.  
  17. CV>Executing cin.clear() resets the ios::failbit and sets ios::goodbit,
  18. CV>and I would expect to be able to use cin again.  However using both
  19. CV>g++ on Unix and Borland C++ I am unable to read anything from cin once
  20. CV>the user types in a letter. What does one do to recover?
  21.  
  22. You have to remove the character from the input e.g. by doing a 
  23.  
  24.     char    no_digit;
  25.     
  26.     cin >> no_digit;
  27.  
  28. After doing that you can start up your reading again.
  29.  
  30. cu
  31.     Torsten
  32.